package com.ruoyi.od.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.od.domain.OdActivity;
import com.ruoyi.od.service.IOdActivityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动审核Controller
 * 
 * @author 榛子
 * @date 2023-07-29
 */
@RestController
@RequestMapping("/od/activity")
public class OdActivityController extends BaseController
{
    @Autowired
    private IOdActivityService odActivityService;

    /**
     * 查询活动审核列表
     */
    @PreAuthorize("@ss.hasPermi('od:activity:list')")
    @GetMapping("/list")
    public TableDataInfo list(OdActivity odActivity)
    {
        startPage();
        List<OdActivity> list = odActivityService.selectOdActivityList(odActivity);
        return getDataTable(list);
    }

    /**
     * 导出活动审核列表
     */
    @PreAuthorize("@ss.hasPermi('od:activity:export')")
    @Log(title = "活动审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OdActivity odActivity)
    {
        List<OdActivity> list = odActivityService.selectOdActivityList(odActivity);
        ExcelUtil<OdActivity> util = new ExcelUtil<OdActivity>(OdActivity.class);
        util.exportExcel(response, list, "活动审核数据");
    }

    /**
     * 获取活动审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('od:activity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(odActivityService.selectOdActivityById(id));
    }

    /**
     * 新增活动审核
     */
    @PreAuthorize("@ss.hasPermi('od:activity:add')")
    @Log(title = "活动审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OdActivity odActivity)
    {
        return toAjax(odActivityService.insertOdActivity(odActivity));
    }

    /**
     * 修改活动审核
     */
    @PreAuthorize("@ss.hasPermi('od:activity:edit')")
    @Log(title = "活动审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OdActivity odActivity)
    {
        return toAjax(odActivityService.updateOdActivity(odActivity));
    }

    /**
     * 删除活动审核
     */
    @PreAuthorize("@ss.hasPermi('od:activity:remove')")
    @Log(title = "活动审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(odActivityService.deleteOdActivityByIds(ids));
    }
}
